Skip to content

refactor(telemetry): centralize sentry.org/project tags in resolution functions#538

Merged
BYK merged 1 commit intomainfrom
refactor/centralize-telemetry-context
Mar 23, 2026
Merged

refactor(telemetry): centralize sentry.org/project tags in resolution functions#538
BYK merged 1 commit intomainfrom
refactor/centralize-telemetry-context

Conversation

@BYK
Copy link
Copy Markdown
Member

@BYK BYK commented Mar 23, 2026

Follows up on #534 which added setContext to issue explain and
issue plan. Rather than playing whack-a-mole with individual commands,
this moves setOrgProjectContext() into the shared resolution functions
that every command already calls.

Problem

~15 commands manually called this.setContext() after resolution, while
~15 others (all dashboard/*, event/view, project/*, trial/*, org/view)
forgot — causing missing sentry.org/sentry.project tags on error
events for those commands.

Solution

Add setOrgProjectContext() calls to the 4 resolution layers:

  • resolve-target.ts — 6 functions (resolveOrgAndProject,
    resolveOrg, resolveAllTargets, resolveOrgProjectTarget,
    resolveProjectBySlug, resolveOrgsForListing)
  • trace-target.ts — 2 functions (resolveTraceOrgProject,
    resolveTraceOrg)
  • dashboard/resolve.tsresolveOrgFromTarget

Then remove setContext from SentryContext interface and all 12
command files that called it manually.

Stats

50 files changed, +85 −350 (net −265 lines)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 23, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (install) Support SENTRY_VERSION env var for version pinning by BYK in #537

Bug Fixes 🐛

Event

  • Detect org/ISSUE-SHORT-ID in event view single-arg path (CLI-9K) by BYK in #529
  • Auto-redirect issue short IDs in event view (CLI-JR) by BYK in #524

Other

  • (api) Strip api/0/ prefix and exclude NodeSystemError integration (CLI-K1) by BYK in #523
  • (dashboard) Add missing datasets to agent guidance by betegon in #522
  • (docs) Overscroll popup — curl command + click-to-copy by betegon in #531
  • (init) Resolve numeric org ID from DSN and prompt when Sentry already configured by betegon in #532
  • (polling) Move spinner from stderr to stdout to prevent consola collision by BYK in #533
  • (telemetry) Set sentry.org tag in issue explain and plan commands by BYK in #534
  • Handle invalid URLs gracefully in response cache (CLI-GC) by BYK in #528
  • Avoid double-prefixing in buildCommandHint for slashed args (CLI-8C) by BYK in #527
  • Handle full short IDs and numeric IDs in multi-slash issue args (CLI-KC, CLI-B6) by BYK in #526
  • Auto-recovery for wrong entity types across commands (CLI-G6, CLI-K6, CLI-JR) by BYK in #525

Documentation 📚

  • (init) Add documentation and experimental notice for sentry init by betegon in #530

Internal Changes 🔧

  • (telemetry) Centralize sentry.org/project tags in resolution functions by BYK in #538
  • Regenerate skill files by github-actions[bot] in 22b5281d

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 23, 2026

Codecov Results 📊

126 passed | Total: 126 | Pass Rate: 100% | Execution Time: 0ms

📊 Comparison with Base Branch

Metric Change
Total Tests
Passed Tests
Failed Tests
Skipped Tests

✨ No test changes detected

All tests are passing successfully.

✅ Patch coverage is 100.00%. Project has 1028 uncovered lines.
✅ Project coverage is 96.02%. Comparing base (base) to head (head).

Files with missing lines (3)
File Patch % Lines
resolve-target.ts 90.59% ⚠️ 69 Missing
org-list.ts 96.16% ⚠️ 18 Missing
view.ts 94.00% ⚠️ 12 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    96.01%    96.02%    +0.01%
==========================================
  Files          185       185         —
  Lines        25757     25805       +48
  Branches         0         0         —
==========================================
+ Hits         24729     24777       +48
- Misses        1028      1028         —
- Partials         0         0         —

Generated by Codecov Action

@BYK BYK force-pushed the refactor/centralize-telemetry-context branch from 8d774b2 to 50b0c0f Compare March 23, 2026 18:44
@BYK BYK marked this pull request as ready for review March 23, 2026 18:49
@BYK BYK force-pushed the refactor/centralize-telemetry-context branch from 50b0c0f to 9e4e6f4 Compare March 23, 2026 19:03
@BYK BYK force-pushed the refactor/centralize-telemetry-context branch from 9e4e6f4 to 7eabcd6 Compare March 23, 2026 19:09
@BYK BYK force-pushed the refactor/centralize-telemetry-context branch from 7eabcd6 to 31b6003 Compare March 23, 2026 19:19
@BYK BYK force-pushed the refactor/centralize-telemetry-context branch from 31b6003 to e148c0a Compare March 23, 2026 19:27
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

…tions

Move setOrgProjectContext() from individual command files into the shared
resolution functions in resolve-target.ts, trace-target.ts, and
dashboard/resolve.ts. This ensures every command that resolves an org or
project automatically gets sentry.org and sentry.project telemetry tags,
eliminating the class of bugs where a command forgets to call setContext().

Previously ~15 commands manually called this.setContext() after resolution,
while ~15 others (all dashboard/*, event/view, project/*, trial/*, org/view)
forgot — causing missing telemetry tags on error events.

Changes:
- Add setOrgProjectContext calls to 6 functions in resolve-target.ts
- Add setOrgProjectContext calls to 2 functions in trace-target.ts
- Add setOrgProjectContext call to resolveOrgFromTarget in dashboard/resolve.ts
- Remove setContext from SentryContext interface and buildContext
- Remove all manual setContext calls from 12 command files
- Update 35 test files to remove setContext from mock contexts
- Delete 7 test blocks that asserted setContext was called
@BYK BYK force-pushed the refactor/centralize-telemetry-context branch from e148c0a to ba22c39 Compare March 23, 2026 19:37
@BYK BYK merged commit 867ab8d into main Mar 23, 2026
22 checks passed
@BYK BYK deleted the refactor/centralize-telemetry-context branch March 23, 2026 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant